package com.just.bz_back.controller.admin;

import com.just.bz_back.model.Part;
import com.just.bz_back.model.PartAdd;
import com.just.bz_back.model.PartUse;
import com.just.bz_back.model.dto.JsonData;
import com.just.bz_back.model.dto.Page;
import com.just.bz_back.service.PartService;
import org.springframework.web.bind.annotation.*;
import reactor.util.annotation.Nullable;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/admin/part")
public class PartController {

    @Resource
    private PartService partService;
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public JsonData CreatePart(@RequestBody @Nullable  Part part)
    {
        partService.CreatePart(part);
        return JsonData.buildSuccess("","添加备件成功！");
    }
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public JsonData PartList(@RequestBody Page page)
    {
        return JsonData.buildSuccess(partService.ListPart(page),"查询备件列表成功！");
    }
    @RequestMapping(value = "/listAll",method = RequestMethod.POST)
    public JsonData PartListAll()
    {
        return JsonData.buildSuccess(partService.PartListAll(),"查询备件成功！");
    }

    /**
     * 查询备件添加列表
     * @param partAdd
     * @return
     */
    @RequestMapping(value = "/listadd",method = RequestMethod.POST)
    public JsonData PartAddList(@RequestBody PartAdd partAdd)
    {
        return JsonData.buildSuccess(partService.PartAddList(partAdd),"查询添加备件列表成功！");
    }

    /**
     * 查询添加列表
     * @param PartUse
     * @return
     */
    @RequestMapping(value = "/listuse",method = RequestMethod.POST)
    public JsonData PartAddList(@RequestBody PartUse PartUse)
    {
        return JsonData.buildSuccess(partService.PartUseList(PartUse),"查询添加备件列表成功！");
    }

}
